#include "AnimationTransform.h"

AnimationTransform::AnimationTransform(void)
{
}

AnimationTransform::~AnimationTransform(void)
{
}


void AnimationTransform::RecalculateMatrix()const
{
	float qx2 = m_Q.x*m_Q.x;
	float qy2 = m_Q.y*m_Q.y;
	float qz2 = m_Q.z*m_Q.z;
	float qw2 = m_Q.w*m_Q.w;

	float a = 1-2*qy2-2*qz2;
	float b = 2*m_Q.x*m_Q.y-2*m_Q.w*m_Q.z;
	float c = 2*m_Q.x*m_Q.z+2*m_Q.w*m_Q.y;

	float d = 2*m_Q.x*m_Q.y+2*m_Q.w*m_Q.z;
	float e = 1-2*qx2-2*qz2;
	float f = 2*m_Q.y*m_Q.z-2*m_Q.w*m_Q.x;

	float g = 2*m_Q.x*m_Q.z-2*m_Q.w*m_Q.y;
	float h = 2*m_Q.y*m_Q.z+2*m_Q.w*m_Q.x;
	float i = 1-2*qx2-2*qy2;

	m_CompiledMatrix.SetRow(0,a,d,g,0);
	m_CompiledMatrix.SetRow(1,b,e,h,0);
	m_CompiledMatrix.SetRow(2,c,f,i,0);
	m_CompiledMatrix.SetRow(3,m_Pivot.x,m_Pivot.y,m_Pivot.z,1);
}